<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/res/include/base-head.jsp"%>
<%@include file="/res/include/jquery-easyui.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/push/push.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/area.js"></script>
</head>
<body>
<form id="data-form">
	<div class="form_item">

		<dl>
			<dt>标题：</dt>
			<dd>
				<input  type="text" class="txt grid-50" id="title" name="title"/>
			</dd>
		</dl>
		<dl>
			<dt>内容：</dt>
			<dd>
				<textarea maxlength="1000" class="txt grid-75" id="content" name="content" rows="4" ></textarea>
			</dd>
		</dl>
		<dl>
			<dt>URL：</dt>
			<dd>
				<input  type="text" class="txt grid-75"  id="url" name="url"/>
			</dd>
		</dl>
		<dl>
			<dt>推送范围：</dt>
			 <dd>
               	省<select name="provinceId" id="provinceId" onchange="admin.area.changeProvince()" class="txt grid-8">
               		<c:forEach var="province" items="${provinceList}">  
                        <option value="${province.id}">${province.name}</option>  
                    </c:forEach>
               	</select>
               	市<select name="cityId" id="cityId" onchange="admin.area.changeCity()" class="txt grid-8">
               		<option value="">--请选择--</option>
               	</select>
               	区<select name="areaId" id="areaId" onchange="admin.area.changeArea()" class="txt grid-8">
               		<option value="">--请选择--</option>
               	</select>
				社区<select name="communityId" id="communityId" class="txt grid-8">
               		<option value="">--请选择--</option>
               	</select>
			</dd>
		</dl>
		
		<dl>
			<dt>店铺：</dt>
			<dd>
				省<select name="provinceId2" id="provinceId2" onchange="changeProvince2()" class="txt grid-8">
               		<c:forEach var="province" items="${provinceList}">  
                        <option value="${province.id}">${province.name}</option>  
                    </c:forEach>
               	</select>
               	市<select name="cityId2" id="cityId2" onchange="changeCity2()" class="txt grid-8">
               		<option value="">--请选择--</option>
               	</select>
               	区<select name="areaId2" id="areaId2" onchange="changeArea2()" class="txt grid-8">
               		<option value="">--请选择--</option>
               	</select>
				社区<select name="communityId2" id="communityId2" onchange="changeCommunity2()"class="txt grid-8">
               		<option value="">--请选择--</option>
               	</select>
				<select id="shopId" name="shopId"  style="padding: 5px;" >
					<option value="">请选择店铺</option>
					<c:forEach items="${mallShopVos}" var="item">
						<option value="${item.id}">${item.name}</option>
					</c:forEach>
				</select>
			</dd>
		<dl>
		<p class="page_btn" id="showBtn">
			<input type="button" id="doPush" value="推送" class="btn_blue" onclick="admin.push.doPush()"/>
		</p>
	</div>
</form>
<script>

window.onload =function()
{
	loadProvinceList2();
}

function loadProvinceList2(){
	var data = {}
	$.post(contextPath+'/sys/area/queryProvinceList',data,function(data) {
		if(data.code==1) {
			var values=[];
			values.push("<option value=''>--请选择--</option>");
			var list=data.map['list'];
			for(var i=0;i<list.length;i++){
				var vo=list[i];
				values.push("<option value="+vo.id+">"+vo.nameAll+"</option>");
			}
			if($("#provinceId2").length>0){
				$("#provinceId2").html(values.join(""));
			}
			if(list.length>0){
				changeProvince2();
			}
		}
	});
}

function changeProvince2(){
	var data = {provinceId:$("#provinceId2").val()}
	$.post(contextPath+'/sys/area/getCityList',data,function(data) {
		if(data.code==1) {
			var values=[];
			values.push("<option value=''>--请选择--</option>");
			var list=data.map['list'];
			for(var i=0;i<list.length;i++){
				var vo=list[i];
				values.push("<option value="+vo.id+">"+vo.nameAll+"</option>");
			}
			if($("#cityId2").length>0){
				$("#cityId2").html(values.join(""));
			}
			if(list.length>0){
				changeCity2();
			}
		}
	});
}
function changeCity2(){
	var data = {cityId:$("#cityId2").val()}
	$.post(contextPath+'/sys/area/getAreaList',data,function(data) {
		if(data.code==1) {
			var values=[];
			values.push("<option value=''>--请选择--</option>");
			var list=data.map['list'];
			for(var i=0;i<list.length;i++){
				var vo=list[i];
				values.push("<option value="+vo.id+">"+vo.nameAll+"</option>");
			}
			
			if($("#areaId2").length>0){
				$("#areaId2").html(values.join(""));
			}
			if(list.length>0){
				changeArea2();
			}
		}
	});
}

function changeArea2(){
	var data = {districtId:$("#areaId2").val()}
	$.post(contextPath+'/community/base/getListByArea',data,function(data) {
		if(data.code==1) {
			var values=[];
			values.push("<option value=''>--请选择--</option>");
			var list=data.map['list'];
			for(var i=0;i<list.length;i++){
				var vo=list[i];
				values.push("<option value="+vo.id+">"+vo.name+"</option>");
			}
			if($("#communityId2").length>0){
				$("#communityId2").html(values.join(""));
			}
		}
	});
}

function changeCommunity2(){
	var communityId4shop = $("#communityId2").val();
	if(communityId4shop=="" || communityId4shop==null){
		return;
	}
	var data = {communityId : communityId4shop}
	$.post(contextPath+'/mall/shop/getListByCommunity',data,function(data) {
		if(data.code==1) {
			var values=[];
			values.push("<option value=''>--请选择店铺--</option>");
			var list=data.map['list'];
			for(var i=0;i<list.length;i++){
				var vo=list[i];
				values.push("<option value="+vo.id+">"+vo.name+"</option>");
			}
			if($("#shopId").length>0){
				$("#shopId").html(values.join(""));
			}
		}
	});
}
</script>
</body>
</html>
